import VueRouter from 'vue-router'

import News from "../pages/student/News";
import Message from "../pages/student/messages/Message";
import Messages from "../pages/student/Messages";
import Student from "../pages/Student";
import Teacher from "../pages/Teacher";
export default new VueRouter({
  // base:'/v2',
  routes:[
    // {
    //   path:'/news',
    //   component:News
    // },{
    //   path:'/messages',
    //   component:Messages
    // },
    {
      name:"s", //可简化访问路径
      path:'/student',
      component:Student,
      children:[
        {
          path:'news',
          component:News
        },{
          path:'messages',
          component:Messages,
          children:[
            // {
            //   name:'mes',
            //   path:'message/:id/:title',
            //   component:Message,
            //   //简化应用时的调用对象，把参数给props,这里只能解决params的传值
            //   props:true
            // },

            //经过反复测试，query和params的传值方式，只能选一个，不能同时在
            //但是都可以使用props方式入参
            {
              name:'mes',
              path:'message',
              component:Message,
              //简化应用时的调用对象，把参数给props,这里只能解决query的传值
              // props(route){
              //   return {
              //     id:route.query.id ,
              //     title:route.query.title
              //   }
              // }
              //解构写法：
              // props({query}){
              //   return {
              //         id: query.id ,
              //         title:query.title
              //       }
              // }
              //连续解构写法：
              props({query:{id,title}}){
                return {
                  id ,
                  title
                }
              }


            },
          ]
        },
      ]
    },{
      path:'/teacher',
      component:Teacher
    }
  ]
})
